/**
 * 
 */
package com.itboye.mengwu.app.ui.main;

import android.util.Log;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.data.interfaces.IUserRepositoryto;
import com.itboye.mengwu.data.model.PersonDataBean;
import com.itboye.mengwu.data.repository.UserRepositoryto;

import java.util.Observer;

/**
 * @author hebidu
 * 
 */
public class MainPresenterto extends BasePresenter {

	//登录
	public static final String LoginSuccessEvent = MainPresenterto.class
			.getName() + "_Login_success";
	public static final String LoginFailureEvent = MainPresenterto.class
			.getName() + "_Login_failure";



	public MainPresenterto(Observer observer) {
		super(observer);
	}


	public void login(String uid, String login_session) {
		IUserRepositoryto<PersonDataBean> repo = new UserRepositoryto(
				new ICompleteListener() {
					@Override
					public void success(ResultEntity result) {
						Log.v("MainPresenter", "login success");
						result.setEventTag(Tag_Success);
						result.setEventType(LoginSuccessEvent);
						MainPresenterto.this.setChanged();
						MainPresenterto.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						Log.v("MainPresenter", "login failure");
						result.setEventTag(Tag_Error);
						result.setEventType(LoginFailureEvent);
						MainPresenterto.this.setChanged();
						MainPresenterto.this.notifyObservers(result);
					}
				});

		PersonDataBean model = new PersonDataBean();
		model.setUid(uid);
		model.setLogin_session_code(login_session);
		repo.login(model);
	}


}
